// 仪表盘
import i18n from '@/lang'
export default {
  initOptions: {
    series: [
      {
        type: 'gauge',
        startAngle: 200,
        endAngle: -20,
        min: 0,
        max: 1,
        splitNumber: 8,
        axisLine: {
          lineStyle: {
            width: 6,
            color: [
              [0.25, '#FF6E76'],
              [0.5, '#FDDD60'],
              [0.75, '#58D9F9'],
              [1, '#7CFFB2']
            ]
          }
        },
        center: ['50%', '50%'],
        radius: '90%',
        pointer: {
          icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
          length: '12%',
          width: 20,
          offsetCenter: [0, '-60%'],
          itemStyle: {
            color: 'auto'
          }
        },
        axisTick: {
          length: 12,
          lineStyle: {
            color: 'auto',
            width: 2
          }
        },
        splitLine: {
          length: 20,
          lineStyle: {
            color: 'auto',
            width: 5
          }
        },
        axisLabel: {
          show: false
        },
        title: {
          offsetCenter: [0, '-20%'],
          fontSize: 16
        },
        detail: {
          fontSize: 30,
          offsetCenter: [0, '0%'],
          valueAnimation: true,
          formatter (value) {
            return Math.round(value * 100) + '%'
          },
          color: 'auto'
        }
      }
    ]

  },
  setEchart (echartObject, result) {
    echartObject.setOption(this.initOptions)
    echartObject.setOption({
      series: [{
        data: [{
          value: result,
          name: i18n.t('missionCompletion')
        }]
      }]
    })
    setTimeout(() => {
      echartObject.resize()
    })
  }
}
